home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / grass / src / battle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.2 KB  |  86 lines

  1.  
  2. /*
  3.     コンピューターのターンのサブルーチンの戦闘のサブルーチン
  4.  
  5.         By 五味
  6.  
  7. */
  8.  
  9.  
  10. #include <stdio.h>
  11. #include <sub.h>
  12.  
  13.     extern    int o,j,i,k[],hp[],s[],thp,b;
  14.     extern    char c,*nn[];
  15.  
  16. struct    attack
  17. {
  18.     char    *how;
  19.     int    damage;
  20. };
  21.  
  22. #include "at_ptn.dat"
  23.  
  24. battle()
  25. {
  26.     while( 0 == 0 )
  27.         {
  28.  
  29.         o = random(3);
  30.  
  31.         if( o==0 )
  32.             {
  33.             o = random(10);
  34.             printf(atmes[b*(j+1)*10+o].how,nn[j+b*20],nn[k[i]]);
  35.             getch();
  36.             hp[i] -= atmes[b*(j+1)*10+o].damage;
  37.  
  38.             if( hp[i] < 1 )
  39.                 {
  40.                 printf("\t%sは死にました…。\n\n",nn[k[i]]);
  41.                 getch();
  42.                 k[i] = -1;
  43.                 return(0);
  44.                 }
  45.  
  46.             }
  47.         else
  48.             {
  49.  
  50.             if( hp[i]+random(5) < (thp/5) )
  51.                 {
  52.                 printf("\t%sは逃走を試みました。\n",nn[k[i]]);
  53.                 getch();
  54.  
  55.                 if( s[k[i]]+random(10) > s[j] )
  56.                     {
  57.         printf("\n %sは、うまく逃げのびたようです。\n\n",nn[k[i]]);
  58.                     getch();
  59.                     return(0);
  60.                     }
  61.                 else
  62.                     {
  63.         printf("\tしかし、逃げる隙をうかがえなかったようです。\n\n");
  64.                     getch();
  65.                     }
  66.  
  67.                 }
  68.             else
  69.                 {
  70.                 o = random(10);
  71.                 printf(atmes[o].how,nn[k[i]],nn[j+20*b]);
  72.                 getch();
  73.                 thp -= atmes[o].damage;
  74.  
  75.                 if( thp < 1 )
  76.                     {
  77.     printf("\n %sを倒しました。\n\n",nn[j+20*b]);
  78.                     getch();
  79.                     return(1);
  80.                     }
  81.                 }
  82.  
  83.             }
  84.         }
  85. }
  86.